﻿@model List<Citi.Scheduler.WebUi.Models.RoutineModel>
@{
    ViewBag.Title = "Routine Hierarchy";
}
<style>
    .itemHierarchy
    {
        width: 200px;
        line-height: 18px;
        min-height: 35px;
        vertical-align: middle;
        text-align: center;
        border: 2px solid darkblue;
        padding: 5px;
        margin: 0 auto;
        margin-left: 15px;
    }
    
    .groupHierarchy
    {
        margin: 0 auto;
        width: 500px;
    }
    
    .currentItemHierarchy
    {
        background-color: lightblue;
    }
</style>
@*<h2>
    Routine Hierarchy</h2>*@
<div style="overflow:auto; width:740px; height:350px;">
    @foreach (var item in Model)
    {
        if (Model.IndexOf(item) == 0)
        {
        @Html.Raw("<div style='clear:both;' class='groupHierarchy'>")
        }
        if (Model.IndexOf(item) > 0 && item.PredecessorRoutineId != Model[Model.IndexOf(item) - 1].PredecessorRoutineId)
        {
        @Html.Raw("</div><div style='clear:both;'>&nbsp;</div><div style='clear:both;' class='groupHierarchy'>")
        }
        <div class="img-rounded floatLeft itemHierarchy @(item.Id == ViewBag.CurrentRoutineId ? "currentItemHierarchy" : string.Empty)">
            @item.Name
            <span style="font-size: 8px">
                <br />
                (@(item.RoutineSchedules.Any() ? item.RoutineSchedules.Last().Schedule.Time.ToString("hh:mm") : "Not Scheduled"))</span>
        </div>
    }
    @Html.Raw("</div>")
</div>
